<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>/home/zjh/git/Koala-UI/KoalaUI/WebContent/lib/Koala_Grid.js</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
            
                <h1><img src="../assets/css/logo.png" title=""></h1>
            
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: </em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
    <h2 class="off-left">APIs</h2>
    <div id="api-tabview" class="tabview">
        <ul class="tabs">
            <li><a href="#api-classes">Classes</a></li>
            <li><a href="#api-modules">Modules</a></li>
        </ul>

        <div id="api-tabview-filter">
            <input type="search" id="api-filter" placeholder="Type to filter APIs">
        </div>

        <div id="api-tabview-panel">
            <ul id="api-classes" class="apis classes">
            
                <li><a href="../classes/Accordion.html">Accordion</a></li>
            
                <li><a href="../classes/AutoComplete.html">AutoComplete</a></li>
            
                <li><a href="../classes/Button.html">Button</a></li>
            
                <li><a href="../classes/Carousel.html">Carousel</a></li>
            
                <li><a href="../classes/ColorPicker.html">ColorPicker</a></li>
            
                <li><a href="../classes/Combobox.html">Combobox</a></li>
            
                <li><a href="../classes/DateTimePicker.html">DateTimePicker</a></li>
            
                <li><a href="../classes/Grid.html">Grid</a></li>
            
                <li><a href="../classes/ListView.html">ListView</a></li>
            
                <li><a href="../classes/Popover.html">Popover</a></li>
            
                <li><a href="../classes/ProgressBar.html">ProgressBar</a></li>
            
                <li><a href="../classes/RichTextEditor.html">RichTextEditor</a></li>
            
                <li><a href="../classes/ScrollSpy.html">ScrollSpy</a></li>
            
                <li><a href="../classes/Select.html">Select</a></li>
            
                <li><a href="../classes/SideBar.html">SideBar</a></li>
            
                <li><a href="../classes/Slider.html">Slider</a></li>
            
                <li><a href="../classes/Spinner.html">Spinner</a></li>
            
                <li><a href="../classes/Tab.html">Tab</a></li>
            
                <li><a href="../classes/ToolBar.html">ToolBar</a></li>
            
                <li><a href="../classes/Tooltip.html">Tooltip</a></li>
            
                <li><a href="../classes/Tree.html">Tree</a></li>
            
                <li><a href="../classes/Wizard.html">Wizard</a></li>
            
            </ul>

            <ul id="api-modules" class="apis modules">
            
            </ul>
        </div>
    </div>
</div>

            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
        Show:
        <label for="api-show-inherited">
            <input type="checkbox" id="api-show-inherited" checked>
            Inherited
        </label>

        <label for="api-show-protected">
            <input type="checkbox" id="api-show-protected">
            Protected
        </label>

        <label for="api-show-private">
            <input type="checkbox" id="api-show-private">
            Private
        </label>
        <label for="api-show-deprecated">
            <input type="checkbox" id="api-show-deprecated">
            Deprecated
        </label>

    </div>


            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
                        <h1 class="file-heading">File: /home/zjh/git/Koala-UI/KoalaUI/WebContent/lib/Koala_Grid.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
/**
 * @author zjh
 */
+function ($) {

	&quot;use strict&quot;;
	
	/**
	 * 表格组件
	 * @class Grid
	 * @constructor
	 * @example
	 * js代码
	 * 	var buttons = [
			{content: &#x27;&lt;button class=&quot;btn btn-primary&quot; type=&quot;button&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-plus&quot;&gt;&lt;span&gt;创建&lt;/button&gt;&#x27;, action: &#x27;add&#x27;},
	        {content: &#x27;&lt;button class=&quot;btn btn-success&quot; type=&quot;button&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-edit&quot;&gt;&lt;/span&gt;&amp;nbsp;修改&lt;/button&gt;&#x27;, action: &#x27;modify&#x27;},
	        {content: &#x27;&lt;button class=&quot;btn btn-danger&quot; type=&quot;button&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-remove&quot;&gt;&lt;/span&gt;&amp;nbsp;删除&lt;/button&gt;&#x27;, action: &#x27;delete&#x27;}
	    ];
	    
	    var columns = [
	    	{title : &quot;角色名称&quot;,name : &quot;name&quot;,width : 250}, 
			{title : &quot;角色描述&quot;,name : &quot;roleDesc&quot;,width : 250}
		];
	 * 	$(&quot;#myGrid&quot;).grid({
			 identity: &#x27;id&#x27;,
             columns: columns,
             buttons: buttons,
             querys: [{title: &#x27;角色名称&#x27;, value: &#x27;name&#x27;},{title: &#x27;角色描述&#x27;, value: &#x27;roleDesc&#x27;}],
             isUserLocalData:true,			//如果为false，则发送ajax请求到url端，获取数据，否则，则视为获取静态数据
             url:&quot;../../common/data.js&quot;,
             localData:staticData
             ,isShowIndexCol:true
             //,lockWidth: true
        });
        
        html代码
        &lt;div id=&quot;myGrid&quot;&gt;&lt;/div&gt;
	 */
	var Grid = function(element, options){
		this.$element = $(element);
		this.options = options;
		this.pageSize = options.pageSize;
		this.pageNo = options.pageNo;
		this.showPage = options.showPage;
		this.searchCondition = {};
        if(typeof options.searchCondition === &#x27;object&#x27;){
            this.searchCondition = options.searchCondition;
        }
        this.sortName = null;
        this.sortOrder = null;
        if(options.sortName){
            this.sortName = options.sortName;
        }
        if(options.sortOrder){
            this.sortOrder = options.sortOrder;
        }
        this.itemsMap = {};
		this._initLayout();
		this._initButtons();
		this._initHead();
		this._initOptions();
		this._initEvents();
		if(this.options.autoLoad){
			var self = this;
			setTimeout(function(){
				self._loadData();
			},0);
		}
	};
	Grid.DEFAULTS = {
		/**
		 * 数据载入时的提示文字
		 * @property loadingText
		 * @type String
		 * @default &#x27;正在载入...&#x27;
		 */
		loadingText: &#x27;正在载入...&#x27;,
		
		/**
		 * 没有数据时的提示文字
		 * @property noDataText
		 * @type String
		 * @default &#x27;没有数据&#x27;
		 */
		noDataText: &#x27;没有数据&#x27;,    
		
		/**
		 * 是否显示索引列
		 * @property isShowIndexCol
		 * @type Boolean
		 * @default true
		 */
		isShowIndexCol: true, //
		
		/**
		 * 是否显示功能按钮
		 * @property isShowButtons
		 * @type Boolean
		 * @default true
		 */
		isShowButtons: true,
		
		/**
		 * 是否表格准备好时加载数据
		 * @property autoLoad
		 * @type Boolean
		 * @default true
		 */
		autoLoad: true, 
		
		/**
		 * 是否显示分页
		 * @property isShowPages
		 * @type Boolean
		 * @default true
		 */
		isShowPages: true, 
		
		/**
		 * 是否使用本地数据源
		 * @property isUserLocalData
		 * @type Boolean
		 * @default false
		 */
        isUserLocalData: false,
        
        /**
		 * 请求数据方式
		 * @property method
		 * @type String
		 * @default &#x27;POST&#x27;
		 */
		method: &#x27;POST&#x27;, 
		
		/**
		 * 主键字段
		 * @property identity
		 * @type String
		 * @default &#x27;id&#x27;
		 */
		identity: &#x27;id&#x27;, 
		
		/**
		 * 是否锁定列宽度
		 * @property lockWidth
		 * @type Boolean
		 * @default false
		 */
		lockWidth: false,
		
		/**
		 * 每页显示多少条数据，采用物理分页方式
		 * @property pageSize
		 * @type Integer
		 * @default 10
		 */
		pageSize: 10,
		
		/**
		 * 当前页，从1开始
		 * @property pageNo
		 * @type Integer
		 * @default 1
		 */
		pageNo: 1,
		
		/**
		 * 分页时显示多少页
		 * @property showPage
		 * @type Integer
		 * @default 4
		 */
		showPage: 4
	};
	Grid.prototype = {
		Constructor: Grid,
		_initLayout: function(){
			this.table = $(Grid.DEFAULTS.TEMPLATE).appendTo(this.$element);
			this.buttons = this.$element.find(&#x27;.buttons&#x27;);
			this.searchContainer = this.$element.find(&#x27;.search&#x27;);
			this.condition = this.searchContainer.find(&#x27;[data-role=&quot;condition&quot;]&#x27;);
			this.totalRecordHtml = this.$element.find(&#x27;[data-role=&quot;total-record&quot;]&#x27;);
			this.startRecord = this.$element.find(&#x27;[data-role=&quot;start-record&quot;]&#x27;);
			this.endRecord = this.$element.find(&#x27;[data-role=&quot;end-record&quot;]&#x27;);
			this.pages = this.$element.find(&#x27;.pages&#x27;);
			this.grid = this.$element.find(&#x27;.grid&#x27;);
			this.gridBody = this.$element.find(&#x27;.grid-body&#x27;).css(&#x27;width&#x27;, this.$element.width());
			this.gridTableHead = this.$element.find(&#x27;.grid-table-head&#x27;);
			this.gridTableHeadTable = this.gridTableHead.find(&#x27;table&#x27;);
			this.gridTableBody = this.$element.find(&#x27;.grid-table-body&#x27;).css(&#x27;width&#x27;, this.$element.width());
			this.gridTableBodyTable = this.gridTableBody.find(&#x27;table&#x27;);
			this.pageSizeSelect = this.$element.find(&#x27;[data-role=&quot;pageSizeSelect&quot;]&#x27;);
			!this.options.isShowButtons &amp;&amp; this.buttons.hide();
			!this.options.isShowPages &amp;&amp; this.grid.find(&#x27;tfoot&#x27;).hide();
			this.colResizePointer = this.table.find(&#x27;.colResizePointer&#x27;);
		},
		_initButtons: function(){
			var self = this;
			var buttons = self.options.buttons;
			if(buttons &amp;&amp; buttons.length &gt; 0){
				 for(var i= 0,j=buttons.length; i&lt;j; i++){
					 var action = buttons[i].action;
					  $(buttons[i].content).appendTo(self.buttons).on(&#x27;click&#x27;, {action: action}, function(e){
						  e.stopPropagation();
						  e.preventDefault();
						  self.$element.trigger(e.data.action, {data:self.selectedRowsIndex(), item: self.selectedRows()});
					  });
				 }
			}else{
				self.options.isShowButtons = false;
			}
		},
		_initHead: function(){
			var self = this;
			var columns = this.options.columns;
			if(!columns || columns.length == 0){
//				$(&#x27;body&#x27;).message({
//					type: &#x27;warning&#x27;,
//					content: &#x27;没有列数据&#x27;
//				});
				return;
			}
			var totalColumnWidth = 0;
			var widthRgExp= /^[1-9]\d*\.?\d*(px){0,1}$/;
			var titleHtml = new Array();
			titleHtml.push(&#x27;&lt;tr&gt;&#x27;);
			if(this.options.isShowIndexCol){
				titleHtml.push(&#x27;&lt;th width=&quot;50px;&quot;&gt;&lt;div class=&quot;checker&quot;&gt;&lt;span data-role=&quot;selectAll&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/th&gt;&#x27;);
			}else{
				titleHtml.push(&#x27;&lt;th width=&quot;50px;&quot; style=&quot;display:none&quot;&gt;&lt;div class=&quot;checker&quot;&gt;&lt;span data-role=&quot;selectAll&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/th&gt;&#x27;);
			}
			for(var i= 0, j=columns.length; i&lt;j; i++){
				var column = columns[i];
				var width = column.width + &#x27;&#x27;;
				titleHtml.push(&#x27;&lt;th index=&quot;&#x27;+i+&#x27;&quot; width=&quot;&#x27;);
				if(width.match(widthRgExp)){
					width = width.replace(&#x27;px&#x27;, &#x27;&#x27;);
					totalColumnWidth +=  parseInt(width);
					titleHtml.push(width +&#x27;px&quot;&#x27;);
				}else{
					titleHtml.push(column.width+&#x27;&quot;&#x27;);
				}
				if(column.sortable &amp;&amp; column.sortName){
					titleHtml.push(&#x27; class=&quot;sort&quot; sortName=&quot;&#x27;+column.sortName+&#x27;&quot; title=&quot;点击排序&quot;&#x27;);
				}
				titleHtml.push(&#x27;&gt;&#x27;);
				titleHtml.push(column.title);
				if(!this.options.lockWidth){
					titleHtml.push(&#x27;&lt;div class=&quot;colResize&quot;&gt;&lt;/div&gt;&#x27;);
				}
				titleHtml.push(&#x27;&lt;/th&gt;&#x27;);
			}
			this.gridTableHeadTable.html(titleHtml.join(&#x27;&#x27;));
			if(totalColumnWidth &gt; this.$element.width()){
				this.gridTableHeadTable.css(&#x27;width&#x27;, totalColumnWidth);
				this.gridTableBodyTable.css(&#x27;width&#x27;, totalColumnWidth);
			}else{
				this.gridTableHead.css(&#x27;width&#x27;, this.$element.width());
				this.gridTableHeadTable.find(&#x27;th:last&#x27;).css(&#x27;width&#x27;, &#x27;auto&#x27;);
				this.options.columns[this.options.columns.length-1].width = &#x27;auto&#x27;;
			}
			this.gridTableHeadTable.find(&#x27;[data-role=&quot;selectAll&quot;]&#x27;).on(&#x27;click&#x27;,function(e) {
				e.stopPropagation();
				var $this = $(this);
				if($this.hasClass(&#x27;checked&#x27;)){
					self.gridTableBodyTable.find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;).each(function(){
						$(this).removeClass(&#x27;checked&#x27;).closest(&#x27;tr&#x27;).removeClass(&#x27;success&#x27;);
					});
				}else{
					self.gridTableBodyTable.find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;).each(function(){
						$(this).addClass(&#x27;checked&#x27;).closest(&#x27;tr&#x27;).addClass(&#x27;success&#x27;);						
					});
				}
				$this.toggleClass(&#x27;checked&#x27;);
			});
			var sorts = this.gridTableHeadTable.find(&#x27;.sort&#x27;);
			sorts.on(&#x27;click&#x27;, function(e){
				e.stopPropagation();
				var $this = $(this);
				self.sortName = $this.attr(&#x27;sortName&#x27;);
				if($this.hasClass(&#x27;sorting-asc&#x27;)){
					sorts.removeClass(&#x27;sorting-asc&#x27;).removeClass(&#x27;sorting-desc&#x27;).find(&#x27;span&#x27;).remove();
					$this.removeClass(&#x27;sorting-asc&#x27;).addClass(&#x27;sorting-desc&#x27;);
					$this.find(&#x27;span&#x27;).remove().end().append($(&#x27;&lt;span class=&quot;glyphicon glyphicon-arrow-down&quot;&gt;&lt;/span&gt;&#x27;));
					self.sortOrder = &#x27;desc&#x27;;
				}else{
					sorts.removeClass(&#x27;sorting-asc&#x27;).removeClass(&#x27;sorting-desc&#x27;).find(&#x27;span&#x27;).remove();
					$this.removeClass(&#x27;sorting-desc&#x27;).addClass(&#x27;sorting-asc&#x27;);
					$this.find(&#x27;span&#x27;).remove().end().append($(&#x27;&lt;span class=&quot;glyphicon glyphicon-arrow-up&quot;&gt;&lt;/span&gt;&#x27;));
					self.sortOrder = &#x27;asc&#x27;;
				}
				self._loadData();
			});
			this.gridTableHeadTable.find(&#x27;.colResize&#x27;).on(&#x27;mousedown&#x27;, function(e){
				e.stopPropagation();
				var $this = $(this);
				var start = e.pageX;
				var left = self.gridTableHead.offset().left;
				self.colResizePointer.css({&#x27;height&#x27;: self.gridBody.height(), &#x27;left&#x27;: e.pageX - self.gridTableBody.scrollLeft() - left}).show();
				self.grid.css({&#x27;-moz-user-select&#x27;: &#x27;none&#x27;, &#x27;cursor&#x27;: &#x27;move&#x27;}).on({
					&#x27;selectstart&#x27;: function (){
						return false;
					},
					&#x27;mousemove&#x27;: function(e){
						self.colResizePointer.css({&#x27;left&#x27;: e.pageX - self.gridTableBody.scrollLeft() - left}).show();
					},
					&#x27;mouseup&#x27;: function(e){
						var end = e.pageX;
						var $th = $this.parent();
						var width = parseFloat($th.attr(&#x27;width&#x27;)) + end - start;
						$th.attr(&#x27;width&#x27;, width);
						var index = $th.attr(&#x27;index&#x27;);
						self.gridTableBodyTable.find(&#x27;td[index=&quot;&#x27;+index+&#x27;&quot;]&#x27;).attr(&#x27;width&#x27;, width);
						$(this).css({&#x27;-moz-user-select&#x27;: &#x27;-moz-all&#x27;, &#x27;cursor&#x27;: &#x27;default&#x27;}).off(&#x27;selectstart&#x27;).off(&#x27;mouseup&#x27;).off(&#x27;mousemove&#x27;);
						self.colResizePointer.hide();
						self.options.columns[index].width = width;
					}
				});
			});
		},
		_initOptions: function(){
			var self = this;
			//每页记录数
			this.pageSizeSelect.select({
				contents: [
					{value: &#x27;5&#x27;, title: &#x27;5&#x27;},
					{value: &#x27;10&#x27;, title: &#x27;10&#x27;},
					{value: &#x27;20&#x27;, title: &#x27;20&#x27;},
					{value: &#x27;50&#x27;, title: &#x27;50&#x27;},
					{value: &#x27;100&#x27;, title: &#x27;100&#x27;}
				]
			});
  			this.pageSizeSelect.setValue(this.options.pageSize).on(&#x27;change&#x27;, function(){
  				self.pageSize = $(this).getValue();
  				self.pageNo = Grid.DEFAULTS.pageNo;
  				self._loadData();
  			});
			if(self.options.querys &amp;&amp; self.options.querys.length&gt;0){
				this.condition.select({
					title: &#x27;选择条件&#x27;,
					contents: self.options.querys
				});
			}else{
				this.searchContainer.hide();
				!this.options.isShowButtons &amp;&amp; this.searchContainer.parent().hide();
			}
		},
		_initEvents: function(){
			var self = this;
			this.gridTableBody.on(&#x27;scroll&#x27;, function(){
				self.gridTableHead.css(&#x27;left&#x27;, -$(this).scrollLeft());
			});
			this.searchContainer.find(&#x27;button[data-role=&quot;searchBtn&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				for(var i=0,j=self.options.querys.length; i&lt;j; i++){
					delete self.searchCondition[self.options.querys[i].value];
				}
				var condition = self.condition.getValue();
				if(!condition){
					$(&#x27;body&#x27;).message({
						type: &#x27;warning&#x27;,
						content: &#x27;请选择查询条件&#x27;
					});
					return;
				}
				var value =  self.searchContainer.find(&#x27;input[data-role=&quot;searchValue&quot;]&#x27;).val().replace(/(^\s*)|(\s*$)/g, &quot;&quot;);
				self.searchCondition[condition] =  value;
				self._loadData();
			});
		},
		/*
		 *加载数据
		 */
		_loadData: function(){
			var self = this;
			var params = {};
			params.pagesize = self.pageSize;
			params.page = self.pageNo;
			for(var prop in self.searchCondition){
				params[prop] = self.searchCondition[prop];
			}
			if(self.sortName &amp;&amp; self.sortOrder){
				params.sortname = self.sortName;
				params.sortorder = self.sortOrder;
			}
            if(self.options.isUserLocalData){
            	var start = self.pageSize * (self.pageNo-1);
            	var end =  self.pageSize * self.pageNo-1;
            	self.totalRecord = self.options.localData.length;
            	self.startRecord.text(start + 1);
				self.endRecord.text(end+1);
				self.totalRecordHtml.text(self.totalRecord);
				self.items = self.getItemsFromLocalData(start, end);
				self._initPageNo(self.totalRecord)
                if(!self.options.localData || self.options.localData.length == 0){
                    self.gridTableBodyTable.empty();
                    self.gridTableBody.find(&#x27;[data-role=&quot;noData&quot;]&#x27;).remove();
                    self.gridTableBody.append($(&#x27;&lt;div data-role=&quot;noData&quot; style=&quot;font-size:16px ; padding: 20px; width:&#x27;+self.gridTableBodyTable.width()+&#x27;px;&quot;&gt;&#x27;+self.options.noDataText+&#x27;&lt;/div&gt;&#x27;));
                }else{
                    self.gridTableBody.find(&#x27;[data-role=&quot;noData&quot;]&#x27;).remove();
                    self.renderDatas();
                }
                return;
            }else{
            	$.ajax({
    				type: this.options.method,
    				url: this.options.url,
    				data: params,
    				dataType: &#x27;json&#x27;
    			}).done(function(result){
    				self._handleResult(self, result);
    			}).fail(function(result){

    			});
            }
			
		},
		/**
		 * 根据开始结束记录数从本地数据获取数据
		 * @method getItemsFromLocalData
		 * @return Array
		 */
		getItemsFromLocalData: function(start, end){
			var items = [];
			if(end &gt; (this.totalRecord - 1)){
				end = this.totalRecord - 1;
			}
			for(var i=start; i&lt;=end; i++){
				items.push(this.options.localData[i]);
			}
			return items;
		},
		/**
		 * 初始化分页
		 * @method _initPageNo
		 */
		_initPageNo: function(){
			var self = this;
			var pageSize = self.pageSizeSelect.getValue();
			this.totalPage = Math.floor(this.totalRecord / pageSize);
			if(this.totalRecord % pageSize != 0){
				this.totalPage ++;
			}
			if(this.totalPage == 0){
				this.pages.hide();
				return;
			}
			var pagination = self.pages.find(&#x27;ul.pagination&#x27;);
			var pageHtml = new Array();
			pageHtml.push(&#x27;&lt;li data-role=&quot;firstPage&quot;&gt;&lt;a href=&quot;#&quot;&gt;&amp;laquo;&lt;/a&gt;&lt;/li&gt;&#x27;);
			pageHtml.push(&#x27;&lt;li data-role=&quot;prev&quot;&gt;&lt;a href=&quot;#&quot;&gt;&amp;lsaquo;&lt;/a&gt;&lt;/li&gt;&#x27;);
			if((self.pageNo-1) % self.showPage == 0){
				self.pageNo != 1 &amp;&amp; pageHtml.push(&#x27;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;...&lt;/a&gt;&lt;/li&gt;&#x27;);
				for(var i=self.pageNo; i&lt;=self.totalPage &amp;&amp; i&lt;(self.pageNo+self.showPage); i++){
					pageHtml.push(&#x27;&lt;li data-value=&quot;&#x27;+i+&#x27;&quot; data-role=&quot;pageNo&quot;&gt;&lt;a href=&quot;#&quot;&gt;&#x27;+i+&#x27;&lt;/a&gt;&lt;/li&gt;&#x27;);
				}
				(self.pageNo + self.showPage) &lt; self.totalPage &amp;&amp; pageHtml.push(&#x27;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;...&lt;/a&gt;&lt;/li&gt;&#x27;);
			}else{
				var start = Math.floor((self.pageNo-1)/self.showPage)*self.showPage+1;
				start != 1 &amp;&amp; pageHtml.push(&#x27;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;...&lt;/a&gt;&lt;/li&gt;&#x27;);
				for(var i=start; i&lt;=self.totalPage &amp;&amp; i&lt;(start+self.showPage); i++){
					pageHtml.push(&#x27;&lt;li data-value=&quot;&#x27;+i+&#x27;&quot; data-role=&quot;pageNo&quot;&gt;&lt;a href=&quot;#&quot;&gt;&#x27;+i+&#x27;&lt;/a&gt;&lt;/li&gt;&#x27;);
				}
				(start + self.showPage) &lt; self.totalPage &amp;&amp; pageHtml.push(&#x27;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;...&lt;/a&gt;&lt;/li&gt;&#x27;);
			}
			pageHtml.push(&#x27;&lt;li data-role=&quot;next&quot;&gt;&lt;a href=&quot;#&quot;&gt;&amp;rsaquo;&lt;/a&gt;&lt;/li&gt;&#x27;);
			pageHtml.push(&#x27;&lt;li data-role=&quot;lastPage&quot; &gt;&lt;a href=&quot;#&quot;&gt;&amp;raquo;&lt;/a&gt;&lt;/li&gt;&#x27;);
			pagination.html(pageHtml.join(&#x27;&#x27;)).find(&#x27;li[data-role=&quot;pageNo&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				self.pageNo = $(this).data(&#x27;value&#x27;);
				self._loadData();
			}).end().find(&#x27;li[data-value=&quot;&#x27;+self.pageNo+&#x27;&quot;]&#x27;).addClass(&#x27;active&#x27;);
			var prevBtn =  pagination.find(&#x27;li[data-role=&quot;prev&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				if($(this).hasClass(&#x27;disabled&#x27;)){
					return;
				}
				self.pageNo-- ;
				self.pageOperateStatus = &#x27;prev&#x27;;
				self._loadData();
			});
			var nextBtn =  pagination.find(&#x27;li[data-role=&quot;next&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				if($(this).hasClass(&#x27;disabled&#x27;)){
					return;
				}
				self.pageNo++ ;
				self.pageOperateStatus = &#x27;next&#x27;;
				self._loadData();
			});
			var firstPageBtn =  pagination.find(&#x27;li[data-role=&quot;firstPage&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				if($(this).hasClass(&#x27;disabled&#x27;)){
					return;
				}
				self.pageNo = 1;
				self._loadData();
			});
			var lastPageBtn =  pagination.find(&#x27;li[data-role=&quot;lastPage&quot;]&#x27;).on(&#x27;click&#x27;, function(){
				if($(this).hasClass(&#x27;disabled&#x27;)){
					return;
				}
				self.pageNo = self.totalPage;
				self._loadData();
			});
			self.pageNo == 1 &amp;&amp; prevBtn.addClass(&#x27;disabled&#x27;) &amp;&amp; firstPageBtn.addClass(&#x27;disabled&#x27;);
			self.pageNo == self.totalPage &amp;&amp; nextBtn.addClass(&#x27;disabled&#x27;) &amp;&amp; lastPageBtn.addClass(&#x27;disabled&#x27;);
		},
		/**
		 * 渲染数据
		 * @method renderDatas
		 */
		renderDatas: function(){
			var self = this;
			self.renderRows();
			self.initSelectRowEvent();
			self.options.isShowPages &amp;&amp; self._initPageNo();
		},
        initSelectRowEvent: function(){
            var self = this;
            var selectAll = self.gridTableHeadTable.find(&#x27;[data-role=&quot;selectAll&quot;]&#x27;);
            var indexCheckboxs = this.gridTableBodyTable.find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;);
            indexCheckboxs.off(&#x27;click&#x27;).on(&#x27;click&#x27;,function(e) {
                e.stopPropagation();
                var $this = $(this);
                if($this.hasClass(&#x27;checked&#x27;)){
                    $this.removeClass(&#x27;checked&#x27;).closest(&#x27;tr&#x27;).removeClass(&#x27;success&#x27;);
                }else{
                    $this.addClass(&#x27;checked&#x27;).closest(&#x27;tr&#x27;).addClass(&#x27;success&#x27;);
                }
                if(self.selectedRowsIndex().length == indexCheckboxs.length){
                    selectAll.addClass(&#x27;checked&#x27;);
                }else{
                    selectAll.removeClass(&#x27;checked&#x27;);
                }
                self.$element.trigger(&#x27;selectedRow&#x27;, {checked: $this.hasClass(&#x27;checked&#x27;), item:self.items[$this.attr(&#x27;indexValue&#x27;)]});
            });
            this.gridTableBodyTable.find(&#x27;tr&#x27;).off(&#x27;click&#x27;).on(&#x27;click&#x27;, function(){
                var $this = $(this);
                if($this.hasClass(&#x27;success&#x27;)){
                    $this.removeClass(&#x27;success&#x27;).find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;).removeClass(&#x27;checked&#x27;);
                }else{
                    $this.addClass(&#x27;success&#x27;).find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;).addClass(&#x27;checked&#x27;);
                }
                self.$element.trigger(&#x27;selectedRow&#x27;, {checked: !$this.hasClass(&#x27;success&#x27;), item:self.items[$this.attr(&#x27;indexValue&#x27;)]});
                if(self.selectedRowsIndex().length == indexCheckboxs.length){
                    selectAll.addClass(&#x27;checked&#x27;);
                }else{
                    selectAll.removeClass(&#x27;checked&#x27;);
                }
            });
        },
		/**
		 * 渲染表格数据
		 * @method renderRows
		 */
		renderRows: function(){
			var self = this;
			if(self.options.tree &amp;&amp; self.options.tree.column){
				self.items = self.initTreeItems(new Array(), self.items);
			}
			var items = self.items;
			var trHtmls = new Array();
			for(var i= 0,j=items.length; i&lt;j; i++){
				var item = items[i];
                self.itemsMap[item.id] = item;
				var trHtml = new Array();
				if(self.options.tree &amp;&amp; self.options.tree.column){
					trHtml.push(&#x27;&lt;tr data-level=&#x27;+item.level+&#x27; data-children=&#x27;+self.getChildrenCount(0, item.children)+&#x27;&gt;&#x27;);
				}else{
					trHtml.push(&#x27;&lt;tr&gt;&#x27;);	
				}
				if(this.options.isShowIndexCol){
					trHtml.push(&#x27;&lt;td width=&quot;50px;&quot;&gt;&lt;div class=&quot;checker&quot;&gt;&lt;span indexValue=&quot;&#x27;+i+&#x27;&quot; data-role=&quot;indexCheckbox&quot; data-value=&quot;&#x27;+item[this.options.identity]+&#x27;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&#x27;);
				}else{
					trHtml.push(&#x27;&lt;td width=&quot;50px;&quot; style=&quot;display:none&quot;&gt;&lt;div class=&quot;checker&quot;&gt;&lt;span indexValue=&quot;&#x27;+i+&#x27;&quot; data-role=&quot;indexCheckbox&quot; data-value=&quot;&#x27;+item[this.options.identity]+&#x27;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;&#x27;);					
				}
				for(var k=0,h=this.options.columns.length; k&lt;h; k++){
					var column = this.options.columns[k];
					trHtml.push(&#x27;&lt;td index=&quot;&#x27;+k+&#x27;&quot; width=&quot;&#x27;+column.width+&#x27;&quot;&#x27;);
					if(column.align){
						trHtml.push(&#x27; align=&quot;&#x27;+column.align+&#x27;&quot;&#x27;);
					}
					trHtml.push(&#x27;&gt;&#x27;);
					if(self.options.tree &amp;&amp; self.options.tree.column 
						&amp;&amp; self.options.tree.column == column.name){
						trHtml.push(&#x27;&lt;div class=&quot;grid-tree-space&quot; style=&quot;padding-left:&#x27;+(parseInt(item.level)-1)*10+&#x27;px;&quot;&gt;&lt;span data-role=&quot;grid-tree-icon&quot; class=&quot;glyphicon glyphicon-folder-open open&quot;&gt;&lt;/span&gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&#x27;);
					}
					if(column.render){
						trHtml.push(column.render(item,column.name,i,k));
					}else{
						trHtml.push(item[column.name]);
					}
					trHtml.push(&#x27;&lt;/td&gt;&#x27;);
				}
				trHtml.push(&#x27;&lt;/tr&gt;&#x27;);
				trHtmls.push(trHtml.join(&#x27;&#x27;));
			}
			this.gridTableBodyTable.html(trHtmls.join(&#x27;&#x27;));
			if(self.options.tree &amp;&amp; self.options.tree.column){
                self.gridTableBodyTable.find(&#x27;[data-role=&quot;grid-tree-icon&quot;]&#x27;).on(&#x27;click&#x27;, function(e){
					e.stopPropagation();
					e.preventDefault();
					var $this = $(this);
					var $tr = $this.closest(&#x27;tr&#x27;);
					var level = parseInt($tr.attr(&#x27;data-level&#x27;));
					var next = $tr.next();
					while(next.length &gt; 0){
						if(level &lt; parseInt(next.attr(&#x27;data-level&#x27;))){
							if($this.hasClass(&#x27;open&#x27;)){
								next.hide();
								next.find(&#x27;[data-role=&quot;grid-tree-icon&quot;]&#x27;).removeClass(&#x27;glyphicon-folder-open&#x27;).addClass(&#x27;glyphicon-folder-close&#x27;);
							}else{
								next.show();
								next.find(&#x27;[data-role=&quot;grid-tree-icon&quot;]&#x27;).addClass(&#x27;glyphicon-folder-open&#x27;).removeClass(&#x27;glyphicon-folder-close&#x27;);
							}
							next = next.next();
						}else{
							break;
						}
					}
					if($this.hasClass(&#x27;open&#x27;)){
						$this.removeClass(&#x27;open&#x27;).removeClass(&#x27;glyphicon-folder-open&#x27;).addClass(&#x27;glyphicon-folder-close&#x27;);
					}else{
						$this.addClass(&#x27;open&#x27;).addClass(&#x27;glyphicon-folder-open&#x27;).removeClass(&#x27;glyphicon-folder-close&#x27;);
					}
				});
			}
		},
        /**
         * 树形表格获取子节点下的所有数量
         * @method getChildrenCount
         */
        getChildrenCount: function(count, items){
            var self = this;
            count += items.length;
            $.each(items, function(){
                if(this.children){
                    count = self.getChildrenCount(count , this.children);
                }
            });
            return count;
        },
		/**
		 * 初始化树形数据
		 * @method initTreeItems
		 */
		initTreeItems: function(newItems, items){
			var self = this;
			for(var i=0,j=items.length; i&lt;j; i++){
				var item = items[i];
				newItems.push(item);
				if(item.children){
					newItems = self.initTreeItems(newItems, item.children);
				}
			}
			return newItems;
		},
		/**
		 * 返回选择行数据的数组。
		 * @method selectedRows
		 * @return Array
		 */
		selectedRows: function(){
			var self = this;
			var selectItems = new Array();
			this.gridTableBodyTable.find(&#x27;.checked[data-role=&quot;indexCheckbox&quot;]&#x27;).each(function(){
				selectItems.push(self.items[$(this).attr(&#x27;indexvalue&#x27;)]);
			});
			return  selectItems;
		},
		/**
		 * 返回选择行的序号列表
		 * @method selectedRowsNo
		 * @return Array
		 */
		selectedRowsNo: function(){
			var selectIndexs = new Array();
			this.gridTableBodyTable.find(&#x27;.checked[data-role=&quot;indexCheckbox&quot;]&#x27;).each(function(){
				selectIndexs.push($(this).attr(&#x27;indexvalue&#x27;));
			});
			return  selectIndexs;
		},
		/**
		 * 返回所有行数据。
		 * @method getAllItems
		 * @return Array
		 */
        getAllItems: function(){
			return this.items;
		},
		/**
		 * 返回选择行索引的数组。
		 * @method selectedRowsIndex
		 * @return Array
		 */
		selectedRowsIndex: function(){
			var selectIndexs = new Array();
			this.gridTableBodyTable.find(&#x27;.checked[data-role=&quot;indexCheckbox&quot;]&#x27;).each(function(){
				selectIndexs.push($(this).attr(&#x27;data-value&#x27;));
			});
			return  selectIndexs;
		},
		/**
		 * 新增一行或多行记录
		 * @method insertRows
		 * @param items(Array)
		 */
		 insertRows: function(items){
		    var self = this;
		    if(!self.items){
		        self.items = new Array();
		        self.gridTableBody.find(&#x27;[data-role=&quot;noData&quot;]&#x27;).remove();
		    }
		    if(items.length){
		        $.each(items, function(){
		            self.items.push(this);
		            self.itemsMap[this[self.options.identity], this];
		        });
		    }else{
		        self.items.push(items);
		        self.itemsMap[items[this.options.identity]] = items;
		    }
		    self.gridTableBodyTable.empty();
		    self.renderDatas();
			return this.$element;
		 },
		 /**
		  * 移除多行
		  * @method removeRows
		  * @param indexs(Array)
		  */
		 removeRows: function(indexs){
		     var self = this;
		     $.each(indexs, function(){
		          var index = self.getIndexByIdentityValue(this);
		          self.items.splice(index, 1);
		          delete self.itemsMap[this];
		     });
		     self.gridTableBodyTable.empty();
		     self.renderDatas();
		 },
		/**
		 * 更新多行数据
		 * @method updateRows
		 * @param currentKeyId
		 * @param item
		 */
		updateRows: function(currentKeyId, item){
			var self = this;
			var index = self.getIndexByIdentityValue(currentKeyId);
			self.items[index] = item;
			self.itemsMap[item[self.options.identity]] = item;
			self.gridTableBodyTable.empty();
			self.renderDatas();
		},
		/**
		 * 根据索引值返回索引列表
		 * @method getIndexByIdentityValue
		 * @param value
		 * @returns Array
		 */
		getIndexByIdentityValue: function(value){
		   return this.gridTableBodyTable.find(&#x27;[data-value=&quot;&#x27;+value+&#x27;&quot;]&#x27;).closest(&#x27;tr&#x27;).index();
		},
		/**
		 * 根据索引返回一行
		 * @method getRowByIndex
		 * @param 索引值
		 * @returns jQuery对象
		 */
		getRowByIndex: function(index){
			return this.gridTableBodyTable.find(&#x27;tr&#x27;).eq(index);
		},
		
		/**
		 * 根据索引返回一行数据
		 * @method getItemByIndex
		 * @param index
		 * @returns json对象
		 */
        getItemByIndex: function(index){
            return this.items[index];
        },
		/**		 
		 * 刷新表格
		 * @method refresh
		 */
		refresh: function(){
			this.pageNo = Grid.DEFAULTS.pageNo;
			this.gridTableHeadTable.find(&#x27;[data-role=&quot;selectAll&quot;]&#x27;).removeClass(&#x27;checked&#x27;);
			this._loadData();
		},
        /**
         * 销毁表格
         * @method destory
         */
        destory: function(){
           this.$element.off().data(&#x27;koala.grid&#x27;, null).empty();
        },
		/**
		 * 外部查询
		 * @method search
		 * @param 查询条件json对象
		 */
		search: function(conditions){
			for(var prop in conditions){
				this.searchCondition[prop] = conditions[prop];
			}
			this._loadData();
		},
		/**
		 * 上移
		 * @method up
		 * @param 索引
		 */
		up: function(index){
            var self = this;
            if(index == 0){
                return;
            }
            var currentRow = self.getRowByIndex(index);
            var prevRow = currentRow.prev(&#x27;tr&#x27;);
            var prevItem = self.items[parseInt(index)-1];
            var currentItem = self.items[index];
            if(self.options.tree &amp;&amp; self.options.tree.column){
                if(parseInt(currentItem.level) &gt; parseInt(prevItem.level)){
                    return false;
                }else{
                    var tempItem = currentRow.prevAll(&#x27;[data-level=&#x27;+currentItem.level+&#x27;]:first&#x27;);
                    if(tempItem.length &gt; 0){
                        var tempIndex = tempItem.index();
                        var upLevel = currentRow.prevAll(&#x27;[data-level=&#x27;+parseInt(currentItem.level-1)+&#x27;]:first&#x27;);
                        if(upLevel.length &gt; 0){
                            if(tempIndex &lt; upLevel.index()){
                                return false;
                            }
                        }
                        prevRow = tempItem;
                    }
                }
            }
            var childrenCount = parseInt(currentRow.attr(&#x27;data-children&#x27;));
            var tempCurrentRow = currentRow.next();
            currentRow.insertBefore(prevRow);
            if(childrenCount &gt; 0){
                for(var i= 0; i &lt; childrenCount; i++){
                    prevRow = currentRow;
                    currentRow = tempCurrentRow;
                    tempCurrentRow = currentRow.next();
                    currentRow.insertAfter(prevRow);
                }
            }
            self.items = new Array();
            self.gridTableBodyTable.find(&#x27;tr&#x27;).each(function(){
                var $this = $(this);
                var indexCheckbox = $this.find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;);
                indexCheckbox.attr(&#x27;indexvalue&#x27;, $this.index());
                self.items.push(self.itemsMap[indexCheckbox.attr(&#x27;data-value&#x27;)]);
            });
            return true;
		},
		/**
		 * 下移
		 * @method down
		 * @param 索引
		 */
		down: function(index){
			var self = this;
		    if(index == self.items.length){
				return;
			}
            var currentRow = self.getRowByIndex(index);
            var nextRow = currentRow.next(&#x27;tr&#x27;);
            var nextItem = self.items[parseInt(index)+1];
			var currentItem = self.items[index];
			if(self.options.tree &amp;&amp; self.options.tree.column){
				if(parseInt(currentItem.level) &gt; parseInt(nextItem.level)){
                    return false;
				}else{
                    var tempItem = currentRow.nextAll(&#x27;[data-level=&#x27;+currentItem.level+&#x27;]:first&#x27;);
                    if(tempItem.length &gt; 0){
                        var tempIndex = tempItem.index();
                        var upLevel = currentRow.nextAll(&#x27;[data-level=&#x27;+parseInt(currentItem.level-1)+&#x27;]:first&#x27;);
                        if(upLevel.length &gt; 0){
                            if(tempIndex &gt; upLevel.index()){
                                return false;
                            }
                        }
                        nextRow = tempItem;
                        var childrenCount = parseInt(tempItem.attr(&#x27;data-children&#x27;));
                        for(var i= 0; i&lt;childrenCount; i++){
                            nextRow = nextRow.next();
                        }
                    }
                }
			}
            var childrenCount = parseInt(currentRow.attr(&#x27;data-children&#x27;));
            var tempCurrentRow = currentRow.next();
            currentRow.insertAfter(nextRow);
            if(childrenCount &gt; 0){
                for(var i= 0; i &lt; childrenCount; i++){
                    nextRow = currentRow;
                    currentRow = tempCurrentRow;
                    tempCurrentRow = currentRow.next();
                    currentRow.insertAfter(nextRow);
                }
            }
            self.items = new Array();
            self.gridTableBodyTable.find(&#x27;tr&#x27;).each(function(){
                var $this = $(this);
                var indexCheckbox = $this.find(&#x27;[data-role=&quot;indexCheckbox&quot;]&#x27;);
                indexCheckbox.attr(&#x27;indexvalue&#x27;, $this.index());
                self.items.push(self.itemsMap[indexCheckbox.attr(&#x27;data-value&#x27;)]);
            });
            return true;
		}
		
		,_handleResult:function(self,result){
			if(!result.Rows){
				$(&#x27;body&#x27;).message({
					type: &#x27;error&#x27;,
					content: &#x27;查询失败&#x27;
				});
				return;
			}
			self.startRecord.text(result.start);
			self.endRecord.text(result.start + result.limit);
			self.totalRecordHtml.text(result.Total);
			self._initPageNo(result.Total)
			self.items = result.Rows;
			self.totalRecord = result.Total;
			if(result.Rows.length == 0){
				self.gridTableBodyTable.empty();
				self.gridTableBody.find(&#x27;[data-role=&quot;noData&quot;]&#x27;).remove();
				self.gridTableBody.append($(&#x27;&lt;div data-role=&quot;noData&quot; style=&quot;font-size:16px ; padding: 20px; width:&#x27;+self.gridTableBodyTable.width()+&#x27;px;&quot;&gt;&#x27;+self.options.noDataText+&#x27;&lt;/div&gt;&#x27;));
			}else{
				self.gridTableBody.find(&#x27;[data-role=&quot;noData&quot;]&#x27;).remove();
				self.renderDatas();
			}
            self.$element.trigger(&#x27;complate&#x27;, result);
		}
	};
	$.fn.getGrid = function(){
		return $(this).data(&#x27;koala.grid&#x27;);
	};
	Grid.DEFAULTS.TEMPLATE = &#x27;&lt;div class=&quot;table-responsive&quot;&gt;&lt;table class=&quot;table table-responsive table-bordered grid&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;div class=&quot;btn-group buttons&quot;&gt;&lt;/div&gt;&lt;div class=&quot;search&quot;&gt;&lt;div class=&quot;btn-group select &quot; data-role=&quot;condition&quot;&gt;&lt;/div&gt;&lt;div class=&quot;input-group&quot; style=&quot;width:180px;&quot;&gt;&lt;input type=&quot;text&quot; class=&quot;input-medium form-control&quot; placeholder=&quot;Search&quot; data-role=&quot;searchValue&quot;&gt;&lt;div class=&quot;input-group-btn&quot;&gt;&lt;button type=&quot;button&quot; class=&quot;btn btn-default&quot; data-role=&quot;searchBtn&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-search&quot;&gt;&lt;/span&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;div class=&quot;colResizePointer&quot;&gt;&lt;/div&gt;&lt;div class=&quot;grid-body&quot;&gt;&lt;div class=&quot;grid-table-head&quot;&gt;&lt;table class=&quot;table table-bordered&quot;&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;grid-table-body&quot;&gt;&lt;table class=&quot;table table-responsive table-bordered table-hover table-striped&quot;&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;tfoot&gt;&lt;tr&gt;&lt;td&gt;&lt;div class=&quot;records&quot;&gt;显示:&lt;span data-role=&quot;start-record&quot;&gt;1&lt;/span&gt;-&lt;span data-role=&quot;end-record&quot;&gt;10&lt;/span&gt;, 共&lt;span data-role=&quot;total-record&quot;&gt;0&lt;/span&gt;条记录。&amp;nbsp;每页显示:&lt;div class=&quot;btn-group select &quot; data-role=&quot;pageSizeSelect&quot;&gt;&lt;/div&gt;条&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;btn-group pages&quot;&gt;&lt;ul class=&quot;pagination&quot;&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tfoot&gt;&lt;/table&gt;&lt;/div&gt;&#x27;;
	var old = $.fn.grid;
	$.fn.grid = function(option){
		return this.each(function(){
			var $this = $(this);
			var data = $this.data(&#x27;koala.grid&#x27;);
			var options = $.extend({}, Grid.DEFAULTS, $this.data(),typeof option == &#x27;object&#x27; &amp;&amp; option);
			//这了为了适应API_Builder的调用，修改一下
//			if(!data){
				$this.data(&#x27;koala.grid&#x27;,(data = new Grid(this, options)));
//			}
			if(typeof option == &#x27;string&#x27;){
				data[option]();
			}
		});
	};
	$.fn.grid.Constructor = Grid;
	$.fn.grid.noConflict = function(){
		$.fn.grid = old;
		return this;
	};
}(window.jQuery);
    </pre>
</div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
